﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace NCEdu.Web.notify
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int notifyId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(notifyId);
				}
			}
		}
			
	private void ShowInfo(int notifyId)
	{
		NCEdu.BLL.notify bll=new NCEdu.BLL.notify();
		NCEdu.Model.notify model=bll.GetModel(notifyId);
		this.lblnotifyId.Text=model.notifyId.ToString();
		this.txtnotifyContent.Text=model.notifyContent;
		this.txtnotifyTitle.Text=model.notifyTitle;
		this.txtpeople.Text=model.people;
		this.txttime.Text=model.time.ToString();
		this.txtoldTime.Text=model.oldTime.ToString();
		this.chkIspush.Checked=model.Ispush;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtnotifyContent.Text.Trim().Length==0)
			{
				strErr+="notifyContent不能为空！\\n";	
			}
			if(this.txtnotifyTitle.Text.Trim().Length==0)
			{
				strErr+="notifyTitle不能为空！\\n";	
			}
			if(this.txtpeople.Text.Trim().Length==0)
			{
				strErr+="people不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txttime.Text))
			{
				strErr+="time格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtoldTime.Text))
			{
				strErr+="oldTime格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int notifyId=int.Parse(this.lblnotifyId.Text);
			string notifyContent=this.txtnotifyContent.Text;
			string notifyTitle=this.txtnotifyTitle.Text;
			string people=this.txtpeople.Text;
			DateTime time=DateTime.Parse(this.txttime.Text);
			DateTime oldTime=DateTime.Parse(this.txtoldTime.Text);
			bool Ispush=this.chkIspush.Checked;


			NCEdu.Model.notify model=new NCEdu.Model.notify();
			model.notifyId=notifyId;
			model.notifyContent=notifyContent;
			model.notifyTitle=notifyTitle;
			model.people=people;
			model.time=time;
			model.oldTime=oldTime;
			model.Ispush=Ispush;

			NCEdu.BLL.notify bll=new NCEdu.BLL.notify();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
